package cn.zcf.org.service.impl;

import cn.zcf.basic.service.impl.BaseServiceImpl;
import cn.zcf.basic.utils.PageList;
import cn.zcf.org.domain.Detail;
import cn.zcf.org.domain.Type;
import cn.zcf.org.mapper.DetailMapper;
import cn.zcf.org.mapper.TypeMapper;
import cn.zcf.org.service.ITypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TypeServiceImpl extends BaseServiceImpl<Type> implements ITypeService {
    @Autowired
    private TypeMapper mapper;
    @Autowired
    private DetailMapper mapper2;


    @Override
    public PageList<Type> loadByx(Long id) {
        return new PageList<>(mapper.xCount(id),mapper.loadByx(id));
    }
    @Override
    public void remove(Long id){
        mapper.remove(id);
        List<Detail> details = mapper2.selectBytId(id);
        for(Detail d:details){
            mapper2.remove(d.getId());
        }
    }
}
